Page({
  data: {
    motto: '',
    userName: '',
    userPassword: '',
    id_token: '',//方便存在本地的locakStorage  
    response: '' //存取返回数据  
  },
  userNameInput: function (e) {
    this.setData({
      userName: e.detail.value
    })
  },
  userPasswordInput: function (e) {
    this.setData({
      userPassword: e.detail.value
    })
  },
  logIn: function () {
    console.log(this.data.userName)
    console.log(this.data.userPassword)
    var that = this
    wx.login({
      success: res => {
        wx.request({
          url: 'https://chnsys-law.com/ecfs-sso-server/bindingRegisterUser',
          data: {
            code: res.code,
            phone_num: this.data.userName,
            password: this.data.userPassword,
          },
          method: 'POST',
          success: function (res) {
            that.setData({
              id_token: res.data.id_token,
              response: res
            })

            if (res.data.code == 200) {
              wx.navigateBack();
<<<<<<< .mine
              try {
                wx.setStorageSync('accessToken', res.data.body.accessToken)
              } catch (e) {
              }
            }else{
=======
            } else {
>>>>>>> .r3545
              wx.showToast({
                title: res.data.msg,
                icon: 'none',
                duration: 3000
              })
            }

            console.log(res.data);
          },
          fail: function (res) {
            console.log(res.data);
            console.log(this.data.userName)
          }
        })
      }
    })
  },

  loginToRegister: function () {
    wx.navigateTo({
      url: '../Register/Register',
    })
  },
  loginToForget: function () {
    wx.navigateTo({
      url: '../ForgetPsd/ForgetPsd',
    })
  }
})



